//
//  CFProgressHUDShowTool.m
//  CFProgressHUD
//
//  Created by 千域互联 on 2018/3/19.
//  Copyright © 2018年 千域互联. All rights reserved.
//

#import "CFProgressHUDShowTool.h"

@interface CFProgressHUDShowTool ()


@end

@implementation CFProgressHUDShowTool

/** 显示用户交互成功或者失败提示HUD */
+ (void)showUserInteractiveIsSuccess:(BOOL)isSuccess inView:(UIView *)targetView title:(NSString *)title
{
    CFProgressHUD *successOrFailureHUD = [[CFProgressHUD alloc] init];
    successOrFailureHUD.textLabel.text = title;

    if (isSuccess) {
        CFProgressHUDSuccessIndicatorView *successIndicator = [[CFProgressHUDSuccessIndicatorView alloc] initWithImage:[UIImage cf_hud_imageWithName:@"cf_hud_user_interactive_success"]];
        successOrFailureHUD.indicatorView = successIndicator;
    }else {
        CFProgressHUDErrorIndicatorView *errorIndicator = [[CFProgressHUDErrorIndicatorView alloc] initWithImage:[UIImage cf_hud_imageWithName:@"cf_hud_user_interactive_error"]];
        successOrFailureHUD.indicatorView = errorIndicator;
    }

    [successOrFailureHUD showInView:targetView];
    [successOrFailureHUD dismissAfterDelay:CFProgressHUDDefaultDismissTimer];
}

/** 显示加载数据成功或者失败提示HUD */
+ (void)showLoadDateIsSuccess:(BOOL)isSuccess inView:(UIView *)targetView title:(NSString *)title
{
    CFProgressHUD *successOrFailureHUD = [[CFProgressHUD alloc] init];
    successOrFailureHUD.textLabel.text = title;

    if (isSuccess) {
        CFProgressHUDSuccessIndicatorView *successIndicator = [[CFProgressHUDSuccessIndicatorView alloc] initWithImage:[UIImage cf_hud_imageWithName:@"cf_hud_load_data_success"]];
        successOrFailureHUD.indicatorView = successIndicator;
    }else {
        CFProgressHUDErrorIndicatorView *errorIndicator = [[CFProgressHUDErrorIndicatorView alloc] initWithImage:[UIImage cf_hud_imageWithName:@"cf_hud_load_data_error"]];
        successOrFailureHUD.indicatorView = errorIndicator;
    }

    [successOrFailureHUD showInView:targetView];
    [successOrFailureHUD dismissAfterDelay:CFProgressHUDDefaultDismissTimer];
}

/** 显示纯文本提示 */
+ (void)showTipMessageInView:(UIView *)targetView title:(NSString *)title;
{
    CFProgressHUD *tipHUD = [[CFProgressHUD alloc] init];
    tipHUD.textLabel.text = title;
    [tipHUD showInView:targetView];
    [tipHUD dismissAfterDelay:CFProgressHUDDefaultDismissTimer];
}

@end
